/*
 * @Author: Liz.Zheng
 * @Date: 2021-09-30 10:13:01
 * @LastEditTime: 2023-02-16 15:08:00
 * @LastEditors: 郑亚莉 zhengyali@shequ.life
 * @Description: 配置vuex以及vuex的持久化存储
 * @Motto: Write the code. Change the world.
 */
import VuexPersist from "vuex-persist";
import {createStore} from "vuex";
import getters from "./getters";
import persistedData from "./modules/persisted";
import globalData from "./modules/global";
import user from "./modules/user";
import layer from "./modules/layer";
import notice from "./modules/notice";
import datav from "./modules/datav";
import building from "./modules/buiilding";
import owner from "./modules/owner";
import search from "./modules/search";
import bill from "./modules/bill";
import contract from "./modules/contract";
import common from "./modules/common";
import defaultSetting from "../common/utils/defaultSetting";
import room from "./modules/room";
import iframeMessage from "./modules/iframeMessage";
import business from './modules/business'
// 创建对象，借助浏览器缓存，存入localStorage
const vuexLocal = new VuexPersist({
  // 存储键名
  key: `${defaultSetting.from}_${defaultSetting.name}_vuex`,
  // 存储方式
  storage: window.localStorage,
  reducer(vuexStore) {
    return {
      // 持久化存储的数据
      persistedData: vuexStore.persistedData,
      datav: vuexStore.datav,
    };
  },
});
// 引入该插件
export default createStore({
  modules: {
    persistedData,
    globalData,
    user,
    layer,
    notice,
    datav,
    building,
    owner,
    search,
    contract,
    bill,
    common,
    room,
    iframeMessage,
    business
  },
  getters,
  state: {},
  mutations: {},
  plugins: [vuexLocal.plugin],
});
